#import "PersonalInfoViewController.h"
#import "UserData.h"
@interface PersonalInfoViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tableview;
@property (nonatomic,strong)NSArray* threelist;
@end

@implementation PersonalInfoViewController

- (UITableView *)tableview{
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];

        _tableview.delegate = self;
        _tableview.dataSource = self;
    }
    return _tableview;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.threelist = @[@"姓名",@"邮箱",@"性别",@"ID",@"班级",@"被点赞数",@"发布内容数",@"受关注数",@"关注数"];
    [self.view addSubview:self.tableview];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 9;
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifier = @"identifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    UserData* user = [UserData shareUser];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    }
    if(indexPath.section == 0){
        cell.textLabel.text = self.threelist[indexPath.row];
        if(indexPath.row == 0){
            cell.detailTextLabel.text = user.Name;
        }
        else if(indexPath.row == 1){
            cell.detailTextLabel.text = user.Email;
        }
        else if(indexPath.row == 2){
            if(user.Gender == 0){
                cell.detailTextLabel.text = @"女";
            }
            else{
                cell.detailTextLabel.text = @"男";
            }
        }
        else if (indexPath.row == 3){
            cell.detailTextLabel.text = user.UserId;
        }
        else if(indexPath.row == 4){
            NSString *n= [NSString stringWithFormat:@"%d",user.Class];
            cell.detailTextLabel.text = n;
        }
        else if(indexPath.row == 5){
            NSString *n= [NSString stringWithFormat:@"%d",user.LikeCount];
            cell.detailTextLabel.text = n;
        }
        else if(indexPath.row == 6){
            NSString *n= [NSString stringWithFormat:@"%d",user.ContentCount];
            cell.detailTextLabel.text = n;
        }
        else if(indexPath.row == 7){
            NSString *n= [NSString stringWithFormat:@"%d",user.FollowerCount];
            cell.detailTextLabel.text = n;
        }
        else if(indexPath.row == 8){
            NSString *n= [NSString stringWithFormat:@"%d",user.FollowingCount];
            cell.detailTextLabel.text = n;
        }
    }
    return cell;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
- (void)viewWillAppear:(BOOL)animated{
    [UserData UpdateUser];
    [self.tableview reloadData];
}

@end
